package com.qfedu.fmshop.controller;


import com.qfedu.fmshop.Vo.CategoryVo;
import com.qfedu.fmshop.beans.IndexImg;
import com.qfedu.fmshop.common.vo.ResStatus;
import com.qfedu.fmshop.common.vo.ResultVO;
import com.qfedu.fmshop.service.IndexService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@CrossOrigin  //允许跨域请求
@RestController
@RequestMapping("/index")
@Api(value = "提供商城首页展示接口",tags = "商城首页")
public class IndexController {

    @Autowired
    private IndexService indexService;

    @ApiOperation("轮播图接口")
    @RequestMapping(value = "/indeximg",method = RequestMethod.GET)
    public ResultVO slideshow(){
        log.info("轮播图接口接收请求！！");

        List<IndexImg> imglist = indexService.slideshow();

        log.info("轮播图接口Controller返回参数：{}",new ResultVO(ResStatus.OK,"",imglist));
//        return new IndexImgVO(imglist);
        return new ResultVO(ResStatus.OK,"",imglist);
    }



    @ApiOperation("分类接口")
    @GetMapping("/category-list")
    public ResultVO Category(){
        List<CategoryVo> categoryVo = indexService.getCategoryVo();
        log.info("商品分类后台接口返回数据：{}",new ResultVO(ResStatus.OK,"",categoryVo));
        return new ResultVO(ResStatus.OK,"",categoryVo);
    }

}
